<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
   
<%@ page import = "java.sql.*" %>
<% String s = null; 
 String s1 = null; 
  String s0 = null; %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Java CRUD Exercise 2.2</title>
</head>
<body style="font-family: arial">
<b>Welcome</b>
<% 
try{
	/** Loading the driver*/
	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

	/** Getting Connection*/
	Connection con = DriverManager.getConnection("jdbc:odbc:jdbctest", "admin", "admin");
	
	/** Creating Statement*/
	Statement stmt = con.createStatement();
	ResultSet rs=stmt.executeQuery("select * from student");

	while(rs.next()) {
		s = rs.getString(1);
		s0 = rs.getString(2);
		s1 = rs.getString(3);
		
		out.println("<br/>Name: " + s);
		out.println("Address: " + s0);
		out.println("Contact #: " + s1);
		s.trim();
		out.println("<a href=\"http://localhost:8080/ex21/Ex22update.jsp?id="+s+"\">update</a>&nbsp<a href=\"http://localhost:8080/ex21/Ex22delete.jsp?id="+s+"\">delete</a>");

		
	}


	/** Closing the Connection*/
	stmt.close();
	con.close();
}
catch (Exception e)
{
	e.printStackTrace();
}
%>
<br/><br/>
<a href="http://localhost:8080/ex21/Ex22Insert.jsp">Insert</a><br/>
<a href="http://localhost:8080/ex21/Ex22delete.jsp">Delete All</a>
</body>
</html>